<template>
  <el-card shadow="always">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="记录明细" name="1">
        <el-row :gutter="20">
          <el-col :span="4">
            <el-cascader
              :options="optionsArea"
              :props="{
                value: 'areaCode',
                label: 'areaName',
                children: 'children',
                checkStrictly: true,
              }"
              ref="cascader"
              @change="CascaderArea"
              :show-all-levels="false"
              v-model="query.areaCode"
            ></el-cascader>
          </el-col>

          <el-col :span="4">
            <el-input
              clearable
              maxlength="50"
              v-model="query.identify"
              placeholder="请输入统一社会信用代码"
            ></el-input>
          </el-col>
          <el-col :span="4">
            <el-input
              maxlength="50"
              clearable
              v-model="query.newLicenseNo"
              placeholder="请输入许可证编号"
            ></el-input>
          </el-col>

          <el-col :span="4">
            <el-input
              clearable
              maxlength="50"
              v-model="query.unitName"
              placeholder="请输入经营者名称"
            ></el-input>
          </el-col>

          <el-col :span="4">
            <el-select
              v-model="query.serveFoodWay"
              clearable
              placeholder="请选择供餐方式"
            >
              <!-- 1 自办食堂、2送餐 -->
              <el-option
                :label="item.label"
                :value="item.value"
                v-for="item in [
                  {
                    value: '1',
                    label: '自办食堂',
                  },
                  {
                    value: '2',
                    label: '送餐',
                  },
                ]"
                :key="item.value"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="4">
            <el-select
              v-model="query.operateWay"
              clearable
              placeholder="请选择经营方式"
            >
              <!-- 1 自办食堂、2送餐 -->
              <el-option
                :label="item.label"
                :value="item.value"
                v-for="item in [
                  {
                    value: '1',
                    label: '自营',
                  },
                  {
                    value: '2',
                    label: '承包或委托经营',
                  },
                ]"
                :key="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-row>

        <rz-height />

        <el-row :gutter="20">
          <el-col :span="4">
            <el-select
              v-model="query.canteenStatistics"
              clearable
              placeholder="请选择食堂分类"
            >
              <!-- 1 自办食堂、2送餐 -->
              <el-option
                :label="item.label"
                :value="item.value"
                v-for="item in [
                  {
                    value: '幼托机构（幼儿园，不包括3岁以下托育机构）',
                    label: '幼托机构（幼儿园，不包括3岁以下托育机构）',
                  },
                  {
                    value: '初等教育学校（小学）',
                    label: '初等教育学校（小学）',
                  },
                  {
                    value: '中等教育学校（初中和高中）',
                    label: '中等教育学校（初中和高中）',
                  },
                  {
                    value: '中等职业教育学校（中专院校、职业高中等）',
                    label: '中等职业教育学校（中专院校、职业高中等）',
                  },
                  {
                    value: '高等教育学校（大专及以上学校）',
                    label: '高等教育学校（大专及以上学校）',
                  },
                ]"
                :key="item.value"
              ></el-option>
            </el-select>
          </el-col>

          <el-col :span="4">
            <el-select
              v-model="query.brightStove"
              clearable
              placeholder="请选择明厨亮灶"
            >
              <!-- 1 自办食堂、2送餐 -->
              <el-option
                :label="item.label"
                :value="item.value"
                v-for="item in [
                  {
                    value: '1',
                    label: '是',
                  },
                  {
                    value: '0',
                    label: '否',
                  },
                ]"
                :key="item.value"
              ></el-option>
            </el-select>
          </el-col>

          <el-col :span="4">
            <el-select
              v-model="query.internetBrightStove"
              clearable
              placeholder="请选择互联网+明厨亮灶"
            >
              <!-- 1 自办食堂、2送餐 -->
              <el-option
                :label="item.label"
                :value="item.value"
                v-for="item in [
                  {
                    value: '1',
                    label: '是',
                  },
                  {
                    value: '0',
                    label: '否',
                  },
                ]"
                :key="item.value"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="4">
            <el-select
              v-model="query.reviewSystem"
              clearable
              placeholder="请选择纳入食材追溯系统"
            >
              <!-- 1 自办食堂、2送餐 -->
              <el-option
                :label="item.label"
                :value="item.value"
                v-for="item in [
                  {
                    value: '1',
                    label: '是',
                  },
                  {
                    value: '0',
                    label: '否',
                  },
                ]"
                :key="item.value"
              ></el-option>
            </el-select>
          </el-col>

          <el-col :span="4">
            <el-select
              v-model="query.system"
              clearable
              placeholder="请选择是否建立HACCP或ISO22000管理体系"
            >
              <!-- 1 自办食堂、2送餐 -->
              <el-option
                :label="item.label"
                :value="item.value"
                v-for="item in [
                  {
                    value: '1',
                    label: '是',
                  },
                  {
                    value: '0',
                    label: '否',
                  },
                ]"
                :key="item.value"
              ></el-option>
            </el-select>
          </el-col>

          <el-col :span="4">
            <el-select
              v-model="query.effectWuChang"
              clearable
              placeholder="请选择是否实施五常、6T等食品安全管理"
            >
              <!-- 1 自办食堂、2送餐 -->
              <el-option
                :label="item.label"
                :value="item.value"
                v-for="item in [
                  {
                    value: '1',
                    label: '是',
                  },
                  {
                    value: '0',
                    label: '否',
                  },
                ]"
                :key="item.value"
              ></el-option>
            </el-select>
          </el-col>
        </el-row>

        <rz-height />

        <el-row :gutter="20">
          <el-col :span="4">
            <el-select
              v-model="query.inviteTenders"
              clearable
              placeholder="请选择公开招标、集中定点采购"
            >
              <!-- 1 自办食堂、2送餐 -->
              <el-option
                :label="item.label"
                :value="item.value"
                v-for="item in [
                  {
                    value: '1',
                    label: '是',
                  },
                  {
                    value: '0',
                    label: '否',
                  },
                ]"
                :key="item.value"
              ></el-option>
            </el-select>
          </el-col>
          <el-col :span="2">
            <el-button
              type="primary"
              @click="
                query.page = 1;
                getList();
              "
              >查询</el-button
            >
          </el-col>
          <el-col :span="2">
            <el-button type="default" @click="getExport">导出</el-button>
          </el-col>
        </el-row>
        <rz-height />
        <el-table border :data="tableData" style="width: 100%" stripe>
          <el-table-column label="区域街道" prop="districtName" width="180">
            <template slot-scope="scope">
              <div>{{ scope.row.sDistrictStreet }}</div>
            </template>
          </el-table-column>

          <el-table-column
            label="统一社会信用代码"
            prop="sIdentify"
            width="180"
          >
          </el-table-column>

          <el-table-column label="单位名称" prop="unitName" width="180">
          </el-table-column>

          <el-table-column label="许可证号" width="180" prop="sNewLicenseNo">
          </el-table-column>

          <el-table-column label="经营者名称" width="180" prop="sOperatorName">
          </el-table-column>

          <el-table-column label="供餐方式" prop="serveFoodWayStr">
          </el-table-column>

          <el-table-column label="经营方式" prop="operateWayStr">
          </el-table-column>

          <el-table-column label="就餐人数" prop="dining"> </el-table-column>

          <el-table-column
            label="食堂分类"
            width="180"
            prop="canteenStatistics"
          >
          </el-table-column>

          <el-table-column label="明厨亮灶" prop="brightStoveStr">
          </el-table-column>

          <el-table-column
            label="互联网+明厨亮灶"
            prop="internetBrightStoveStr"
          >
          </el-table-column>

          <el-table-column label="纳入食材追溯系统" prop="reviewSystemStr">
          </el-table-column>

          <el-table-column
            label="是否建立HACCP或ISO22000管理体系"
            prop="systemStr"
          >
          </el-table-column>

          <el-table-column
            label="是否实施五常、6T等食品安全管理"
            prop="effectWuChangStr"
          >
          </el-table-column>

          <el-table-column
            label="公开招标、集中定点采购"
            prop="inviteTendersStr"
          >
          </el-table-column>

          <el-table-column
            label="操作"
            prop="indexScore"
            width="160"
            fixed="right"
          >
            <template slot-scope="scope">
              <el-button type="primary" size="mini" @click="edit(scope.row)"
                >编辑</el-button
              >
              <el-button type="default" size="mini" @click="view(scope.row)"
                >查看</el-button
              >
            </template>
          </el-table-column>

          <!-- 列表：区域街道、统一社会信用代码、单位名称、许可证号、经营者名称、供餐方式、经营方式、就餐人数、食堂分类、明厨亮灶、互联网+明厨亮灶、纳入食材追溯系统
、是否建立HACCP或ISO22000管理体系、是否实施五常、6T等食品安全管理、公开招标、集中定点采购、操作（查看、编辑） -->

          <!-- <template slot-scope="scope">
                 <div v-if="scope.row.unitstatus">
                   <el-tag type="success" v-if="scope.row.unitstatus=='在业'">{{ scope.row.unitstatus }}</el-tag>
                   <el-tag type="danger" v-else>{{ scope.row.unitstatus }}</el-tag>
                 </div>
                 <el-tag type="danger" v-else>--</el-tag>

                  
              </template> -->
        </el-table>
        <pagination
          :total="total"
          :page.sync="query.page"
          @pagination="getList"
          v-show="total"
        />
      </el-tab-pane>
      <el-tab-pane label="统计表" name="2">
        <el-row :gutter="20">
          <el-col :span="4">
            <el-cascader
              :options="optionsArea"
              :props="{
                value: 'areaCode',
                label: 'areaName',
                children: 'children',
                checkStrictly: true,
              }"
              ref="cascader"
              @change="CascaderAreaA"
              :show-all-levels="false"
              v-model="areaCode"
            ></el-cascader>
          </el-col>
          <el-col :span="2">
            <el-button type="primary" @click="allList()">查询</el-button>
          </el-col>
          <el-col :span="2">
            <el-button @click="exportTable()">导出</el-button>
          </el-col>
        </el-row>
        <rz-height />
        <el-table
          class="region"
          :data="tableDataA"
          :span-method="arraySpanMethod"
          border
          stripe
          style="width: 100%"
        >
          <el-table-column prop="largeCategoryStr" label="指标名称">
          </el-table-column>
          <el-table-column prop="categoryStr" label=""> </el-table-column>
          <el-table-column prop="name" label="单位">
            <template slot-scope="scope">
              <div v-if="scope.$index == 1">所</div>
              <div v-else>家</div>
            </template>
          </el-table-column>
          <el-table-column prop="ytjgToal" label="幼托机构"> </el-table-column>
          <el-table-column prop="cdjyTotal" label="初等教育学学校">
          </el-table-column>
          <el-table-column prop="zdjyTotal" label="中等教育学校">
          </el-table-column>
          <el-table-column prop="zdzyTotal" label="中等职业教育学校">
          </el-table-column>
          <el-table-column prop="gdjyTotal" label="高等教育学校">
          </el-table-column>
          <el-table-column prop="qtjyToal" label="其他"> </el-table-column>
          <el-table-column prop="unitsTotal" label="合计"> </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="学校管理" name="3">  
        <school/>
      </el-tab-pane>
    </el-tabs>
    <rz-dialog
      :dialogVisible.sync="dialogVisible"
      title="修改食堂信息"
      width="60%"
      confirmName="保存"
      @onconfirm="onconfirm"
    >
      <el-form ref="form1" :model="modifyForm" label-width="180px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="食堂分类">
              <el-select
                v-model="modifyForm.canteenStatistics"
                placeholder="请选择食堂分类"
              >
                <el-option
                  v-for="item in [
                    {
                      label: '幼托机构（幼儿园，不包括3岁以下托育机构）',
                      value: '幼托机构（幼儿园，不包括3岁以下托育机构）',
                    },
                    {
                      label: '初等教育学校（小学）',
                      value: '初等教育学校（小学）',
                    },
                    {
                      label: '中等教育学校（初中和高中）',
                      value: '中等教育学校（初中和高中）',
                    },
                    {
                      label: '中等职业教育学校（中专院校、职业高中等）',
                      value: '中等职业教育学校（中专院校、职业高中等）',
                    },
                    {
                      label: '高等教育学校（大专及以上学校）',
                      value: '高等教育学校（大专及以上学校）',
                    },
                  ]"
                  :key="item.index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="12">
            <el-form-item label="明厨亮灶">
              <el-select
                v-model="modifyForm.brightStove"
                placeholder="请选择明厨亮灶"
              >
                <el-option
                  v-for="item in [
                    {
                      label: '是',
                      value: 1,
                    },
                    {
                      label: '否',
                      value: 0,
                    },
                  ]"
                  :key="item.index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select> </el-form-item
          ></el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="互联网+明厨亮灶">
              <el-select
                v-model="modifyForm.internetBrightStove"
                placeholder="请选择互联网+明厨亮灶"
              >
                <el-option
                  v-for="item in [
                    {
                      label: '是',
                      value: 1,
                    },
                    {
                      label: '否',
                      value: 0,
                    },
                  ]"
                  :key="item.index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="12">
            <el-form-item label="公开招标、集中定点采购">
              <el-select
                v-model="modifyForm.inviteTenders"
                placeholder="请选择公开招标、集中定点采购"
              >
                <el-option
                  v-for="item in [
                    {
                      label: '是',
                      value: 1,
                    },
                    {
                      label: '否',
                      value: 0,
                    },
                  ]"
                  :key="item.index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select> </el-form-item
          ></el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="纳入食材追溯系统">
              <el-select
                v-model="modifyForm.reviewSystem"
                placeholder="请选择纳入食材追溯系统"
              >
                <el-option
                  v-for="item in [
                    {
                      label: '是',
                      value: 1,
                    },
                    {
                      label: '否',
                      value: 0,
                    },
                  ]"
                  :key="item.index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="12">
            <el-form-item
              label="是否建立HACCP或ISO22000管理体系"
              label-width="280px"
            >
              <el-radio-group v-model="modifyForm.system">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="供餐方式">
              <el-select
                v-model="modifyForm.serveFoodWay"
                placeholder="请选择供餐方式"
              >
                <el-option
                  v-for="item in [
                    {
                      label: '自办食堂',
                      value: 1,
                    },
                    {
                      label: '送餐',
                      value: 2,
                    },
                  ]"
                  :key="item.index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="12">
            <el-form-item label="经营方式">
              <el-select
                v-model="modifyForm.operateWay"
                placeholder="请选择经营方式"
              >
                <el-option
                  v-for="item in [
                    {
                      label: '自营',
                      value: 1,
                    },
                    {
                      label: '承包或委托经营',
                      value: 2,
                    },
                  ]"
                  :key="item.index"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item
              label="是否实施五常、6T等食品安全管理"
              label-width="280px"
            >
              <el-radio-group v-model="modifyForm.effectWuChang">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="供餐人数">
              <el-input
                v-model="modifyForm.dining"
                v-number
                placeholder="请输入供餐人数"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="学校主管部门">
              <el-input
                v-model="modifyForm.schoolDepartment"
                type="textarea"
                placeholder="请输入学校主管部门"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </rz-dialog>

    <rz-dialog
      :dialogVisible.sync="dialogVisibleView"
      title="食堂基本信息"
      width="60%"
      :isShowConfirm="false"
    >
      <el-form ref="form" :model="form" label-width="280px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="供餐方式">
              <div v-if="form.serveFoodWay == '1'">自办食堂</div>
              <div v-else-if="form.serveFoodWay == '2'">送餐</div>
            </el-form-item></el-col
          >
          <el-col :span="12">
            <el-form-item label="经营方式">
              <div v-if="form.operateWay == '1'">自营</div>
              <div v-else-if="form.operateWay == '2'">承包或委托经营</div>
            </el-form-item></el-col
          >
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="就餐人数">
              {{ form.dining }}
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="纳入食材追溯系统" prop="reviewSystem">
              <!-- {{ form.reviewSystem }} -->
              <div v-if="form.reviewSystem == '1'">是</div>
              <div v-else-if="form.reviewSystem == '0'">否</div>
            </el-form-item></el-col
          >
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="明厨亮灶">
              <!-- {{ form.brightStove }} -->
              <div v-if="form.brightStove == '1'">是</div>
              <div v-else-if="form.brightStove == '0'">否</div>
            </el-form-item></el-col
          >

          <el-col :span="12">
            <el-form-item label="互联网+明厨亮灶">
              <!-- {{ form.internetBrightStove }} -->
              <div v-if="form.internetBrightStove == '1'">是</div>
              <div v-else-if="form.internetBrightStove == '0'">否</div>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="食堂分类">
              {{ form.canteenStatistics }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否建立HACCP或ISO22000管理体系">
              <div v-if="form.system == '1'">是</div>
              <div v-else-if="form.system == '0'">否</div>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="公开招标、集中定点采购">
              <div v-if="form.inviteTenders == '1'">是</div>
              <div v-else-if="form.inviteTenders == '0'">否</div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否实施五常、6T等食品安全管理">
              <div v-if="form.effectWuChang == '1'">是</div>
              <div v-else-if="form.effectWuChang == '0'">否</div>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="学校主管部门" prop="schoolDepartment">
              {{ form.schoolDepartment }}
            </el-form-item>
          </el-col>
        </el-row>
        <template v-if="form.serveFoodWay == 2">
          <div>
            <h3>校外供餐配送单位</h3>
            <rz-height />
            <el-table :data="tableData1" border style="width: 100%">
              <el-table-column
                prop="unitName"
                label="主体名称"
              ></el-table-column>
              <el-table-column
                prop="identify"
                label="统一社会信用代码"
              ></el-table-column>
              <el-table-column
                prop="newLicenseNo"
                label="食品经营许可证"
              ></el-table-column>
            </el-table>
          </div>
        </template>
        <template v-if="form.operateWay == 2">
          <div>
            <h3>承包商</h3>
            <rz-height />
            <el-table :data="tableData2" border style="width: 100%">
              <el-table-column
                prop="unitName"
                label="主体名称"
              ></el-table-column>
              <el-table-column
                prop="identify"
                label="统一社会信用代码"
              ></el-table-column>
              <el-table-column
                prop="newLicenseNo"
                label="食品经营许可证"
              ></el-table-column>
              <!-- <el-table-column prop="newLicenseNo" label="操作">
              </el-table-column> -->
            </el-table>
          </div>
        </template>
      </el-form>
    </rz-dialog>
  </el-card>
</template>
<script>
import {
  groupArea,
  findCanteenManageList,
  saveCanteenManage,
  findCanteenManage,
  exportCanteenManageList,
  canteenManageStatistics,
  //   viseUnitListSuper,
  //   exportqueryPeopleInfoNew,
  //   // sysDicUnitLabel,
  //   saveSuperViseUnitLabel,
} from "@/api/modules/enterprise";
import { exportTb } from "@/utils/XLSX";
export default {
  name: "CanteenAnalysis",
  // props:[],
  // 页面加载
  created() {
    this.getCode();
    this.getList();
    this.allList();
  },
  // 页面加载完成
  mounted() {},
  //实例销毁之前
  beforeDestroy() {},
  //实例销毁后
  destroyed() {},
  data() {
    return {
      tableDataA: [],
      dialogVisible: false,
      activeName: "1",
      query: {
        areaCode: this.$route.query.code||'320500000000',
        brightStove: "",
        canteenStatistics: "",
        effectWuChang: "",
        identify: "",
        internetBrightStove: "",
        inviteTenders: "",
        isPage: 0,
        newLicenseNo: "",
        operateWay: "",
        page: 1,
        pageSize: 10,
        reviewSystem: "",
        serveFoodWay: "",
        system: "",
        unitName: "",
      },
      optionsArea: [],
      total: 0,
      modifyForm: {
        id: "",
        canteenStatistics: "",
        brightStove: "",
        internetBrightStove: "",
        reviewSystem: "",
        effectWuChang: "",
        system: "",
        inviteTenders: "",
        schoolDepartment: "",
        serveFoodWay: "",
        operateWay: "",
        dining: "",
      },
      form: {
        dining: "",
        effectWuChang: 1,
        operateWay: "",
        serveFoodWay: "",
        system: 1,
        unitName: "",
        schoolDepartment: "",
        id: "",
        canteenStatistics: "",
        brightStove: "",
        internetBrightStove: "",
        reviewSystem: "",
        inviteTenders: "",
      },
      tableData1: [],
      tableData2: [],
      dialogVisibleView: false,
      tableData: [],
      areaCode:  this.$route.query.code||'320500000000',

     
    };
  },
  // 方法
  methods: {
    handerMethod({ row, column, rowIndex, columnIndex }) {
      if (row[0].level == 1) {
        //这里有个非常坑的 bug 必须是 row[0]=0 row[1]=2 才会生效
        row[0].colSpan = 2;
        row[1].colSpan = 0;
        if (columnIndex === 1) {
          return { display: "none" };
        }
        // if (columnIndex === 3) {
        // return { display: 'none' }
        // }
      }
    },
    exportTable() {
      let time = new Date().getTime();
      exportTb(".region", `导出${time}`);
    },
    arraySpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 0) {
        if (rowIndex === 13) {
          return [1, 2];
        }
        if (rowIndex === 14) {
          return [1, 2];
        }
        if (
          rowIndex === 0 ||
          rowIndex === 2 ||
          rowIndex === 4 ||
          rowIndex === 9 ||
          rowIndex === 11
        ) {
          return {
            rowspan: 2,
            colspan: 1,
          };
        } else if (rowIndex === 6) {
          return {
            rowspan: 3,
            colspan: 1,
          };
        } else if (rowIndex === 13 || rowIndex === 14) {
          return {
            rowspan: 1,
            colspan: 1,
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      } else if (columnIndex === 1) {
        if (rowIndex === 13) {
          return [0, 0];
        }
        if (rowIndex === 14) {
          return [0, 0];
        }
      }
    },
    async allList() {
      let res = await canteenManageStatistics({
        params: {
          areaCode: this.areaCode,
        },
      });
      this.tableDataA = res.data;
    },
    getExport(e) {
      exportCanteenManageList(this.query).then((res) => {
        var blob = new Blob([res], {
          type: "application/vnd.ms-excel;charset=utf-8",
        });
        var downloadElement = document.createElement("a");
        var href = window.URL.createObjectURL(blob); //创建下载的链接
        downloadElement.href = href;
        downloadElement.download = "导出" + new Date().getTime() + ".xlsx"; //下载后文件名
        document.body.appendChild(downloadElement);
        downloadElement.click(); //点击下载
        document.body.removeChild(downloadElement); //下载完成移除元素
        window.URL.revokeObjectURL(href); //释放掉blob对象
      });
    },
    edit(e) {
      let data = this.$_.cloneDeep(e);
      this.modifyForm.canteenStatistics = data.canteenStatistics;
      this.modifyForm.id = data.id;
      this.modifyForm.brightStove = data.brightStove;
      this.modifyForm.internetBrightStove = data.internetBrightStove;
      this.modifyForm.reviewSystem = data.reviewSystem;
      this.modifyForm.inviteTenders = data.inviteTenders;
      this.modifyForm.effectWuChang = data.effectWuChang;
      this.modifyForm.system = data.system;
      this.modifyForm.schoolDepartment = data.schoolDepartment;
      this.modifyForm.serveFoodWay = data.serveFoodWay;
      this.modifyForm.operateWay = data.operateWay;
      this.modifyForm.dining = data.dining;
      this.dialogVisible = true;
    },
    async onconfirm() {
      if (this.modifyForm.schoolDepartment == "")
        return this.$error("请输入学校主管部门");
      if (this.modifyForm.serveFoodWay == "")
        return this.$error("请选择供餐方式");
      if (this.modifyForm.operateWay == "")
        return this.$error("请选择经营方式");
      if (this.modifyForm.dining == "") return this.$error("请输入供餐人数");

      let res = await saveCanteenManage(this.modifyForm);
      this.$success(res.msg);
      this.dialogVisible = false;
      this.getList();
    },
    async view(e) {
      let res = await findCanteenManage({
        params: {
          id: e.id,
        },
      });
      this.form.dining = res.data.dining;
      this.form.effectWuChang = res.data.effectWuChang;
      this.form.operateWay = res.data.operateWay;
      this.form.serveFoodWay = res.data.serveFoodWay;
      this.form.system = res.data.system;
      this.form.id = res.data.id;
      this.form.unitName = res.data.unitName;
      this.form.schoolDepartment = res.data.schoolDepartment;
      this.form.canteenStatistics = res.data.canteenStatistics;
      this.form.brightStove = res.data.brightStove;
      this.form.internetBrightStove = res.data.internetBrightStove;
      this.form.reviewSystem = res.data.reviewSystem;
      this.form.inviteTenders = res.data.inviteTenders;
      this.tableData1 = res.data.findManageUnitResponseList.filter(
        (x) => x.category == 1
      );
      this.tableData2 = res.data.findManageUnitResponseList.filter(
        (x) => x.category == 2
      );
      this.dialogVisibleView = true;
    },
    handleClick() {
      console.log(1212);
    },
    getCode() {
      groupArea({
        params: {
          areaCode: this.query.areaCode,
        },
      }).then((res) => {
        this.optionsArea = [res.data];
      });
    },
    CascaderArea(e) {
      this.query.areaCode = e[e.length - 1];
    },
    CascaderAreaA(e) {
      this.areaCode = e[e.length - 1];
    },
    getList() {
      findCanteenManageList(this.query).then((res) => {
        this.tableData = res.data.list;
        this.total = res.totalCount;
      });
    },
  },
  // 监听属性
  watch: {},
  // 组件
  components: {
    school: () =>import("@/views/foodSafety/Canteenanalysis/school")

    //  component: () => import("@/views/foodSafety/Canteenanalysis/Canteenanalysis"),
  },
  // 计算属性
  computed: {},
};
</script>

<style lang="scss" scoped>
/deep/ .has-gutter tr :nth-child(1) {
  border-right: none;
}
</style>
